// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { videoAds } = require("./ads/video");
const { show } = require("./game/alert");
const { ListViewAdapter } = require("./ListView/ListViewAdapter");
const { achieveList, achieveProcess, player, shopData } = require("./shop/gameData");

cc.Class({
    extends: cc.Component,

    properties: {
       list: ListViewAdapter
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad() {
        
    },
    onEnable () {
        //获取金钱的多少
        achieveProcess.money = player.money;
        let count = 0;
        shopData.shopList.forEach(val => {
            if(val.status == 1) {
                count ++;
            }
        })
        achieveProcess.shop = (count - 1) < 0? 0: (count - 1);
        this.list.updateItems(achieveList);
    },
    loadAds(){
        videoAds.showAd((res=>{
           if(res){
            show("未来人生工作室","感谢支持");
           }
        }))
    }
    // update (dt) {},
});
